package com.abs.orm.convert.util;

import java.io.Serializable;

import com.abs.orm.util.StringUtil;
import com.ads.orm.model.j.JField;
import com.ads.orm.model.j.JMethod;

public class ConvertUtil implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6802188627431014527L;

	public static StringBuffer convert2Attribute(JField arg0) {
		StringBuffer sb = new StringBuffer();
		sb.append("\t");
		sb.append(arg0.getModifier());
		sb.append(" ");
		sb.append(arg0.getClazz());
		sb.append(" ");
		sb.append(arg0.getName());
		sb.append(";");
		sb.append("\n");
		return sb;
	}

	public static StringBuffer convert2Get(JMethod arg0) {
		StringBuffer sb = new StringBuffer();
		sb.append("\n");
		sb.append("\t");
		sb.append(arg0.getModifier());
		sb.append(" ");
		sb.append(arg0.getClazz());
		sb.append(" ");
		sb.append("get");
		sb.append(StringUtil.toFirstUpper(arg0.getName()));
		sb.append("()");
		sb.append(" ");
		sb.append("{");
		sb.append("\n");
		sb.append("\t");
		sb.append("\t");
		sb.append("return");
		sb.append(" ");
		sb.append(arg0.getName());
		sb.append(";");
		sb.append("\n");
		sb.append("\t");
		sb.append("}");
		sb.append("\n");
		return sb;
	}

	public static StringBuffer convert2Set(JMethod arg0) {
		StringBuffer sb = new StringBuffer();
		sb.append("\n");
		sb.append("\t");
		sb.append(arg0.getModifier());
		sb.append(" ");
		sb.append(arg0.getReturnClazz());
		sb.append(" ");
		sb.append("set");
		sb.append(StringUtil.toFirstUpper(arg0.getName()));
		sb.append("(");
		sb.append(arg0.getClazz());
		sb.append(" ");
		sb.append(arg0.getName());
		sb.append(")");
		sb.append(" ");
		sb.append("{");
		sb.append("\n");
		sb.append("\t");
		sb.append("\t");
		sb.append("this.");
		sb.append(arg0.getName());
		sb.append("=");
		sb.append(arg0.getName());
		sb.append(";");
		sb.append("\n");
		sb.append("\t");
		sb.append("}");
		sb.append("\n");
		return sb;
	}
}
